import os
import shutil


def delete_folders(directory):
    folders_to_delete = ['build', 'dist']

    for root, dirs, files in os.walk(directory):
        for folder in dirs:
            if folder in folders_to_delete:
                folder_path = os.path.join(root, folder)
                try:
                    # 使用shutil.rmtree()函数删除文件夹及其内容
                    shutil.rmtree(folder_path)
                    print(f"Folder {folder_path} deleted successfully.")
                except OSError as e:
                    print(f"Error: {e.strerror}")
    后缀=[".exe"]
    # 列出指定目录下的所有文件
    files = os.listdir(directory_path)
    # 删除后缀为".exe"的文件
    for file in files:
        for 后缀名 in 后缀:
            if file.endswith(后缀名):
                file_path = os.path.join(directory_path, file)
                os.remove(file_path)
                print(f"File {file_path} deleted successfully.")
# 指定目录路径
directory_path = os.getcwd()

delete_folders(directory_path)
print("执行完毕")

